Skip to main content

Jupyter Architecture

Overview

Jupyter architecture implements a two-process model involving a kernel and a client. This design allows for the execution of code and the display of results through an interactive interface.

Key Components

Client

  • Role: The client serves as the user interface, allowing code to be sent to the kernel.
  • Example: In Jupyter Notebooks, the client is the browser interface where users interact with their notebooks.

Kernel

  • Role: The kernel is responsible for executing the code provided by the client and returning the results.
  • Function: Executes code cells and sends the output back to the client for display.

Notebook Server

  • Role: The server manages the saving and loading of notebooks.
  • Function: Receives notebooks from the browser, saves them as JSON files with a .ipynb extension, and loads them when requested.

Notebook Structure

Jupyter Notebooks encapsulate:

  • Code: Source code written by the user.
  • Metadata: Additional information about the notebook and its content.
  • Contents: The main body of the notebook including text, images, and other media.
  • Outputs: Results generated from executing the code cells.

File Saving and Format

  • Saving: When a notebook is saved, it is sent from the browser to the Notebook server, which stores it as a JSON file with a .ipynb extension.
  • Loading: The Notebook server loads the notebook file when accessed by the user.

File Conversion with NBConvert

Process

  1. Preprocessing: The notebook file is initially modified by a preprocessor.
  2. Exporting: An exporter converts the preprocessed notebook to the desired format (e.g., HTML).
  3. Postprocessing: A postprocessor works on the exported file to produce the final output.

Example: Converting to HTML

  • The notebook is first modified by a preprocessor.
  • An exporter converts the notebook to an HTML file.
  • A postprocessor finalizes the HTML file for display.

Summary

  • Jupyter architecture utilizes a two-process model consisting of a kernel and a client.
  • The Notebook server is responsible for saving and loading notebooks.
  • The kernel executes the code cells within a notebook.
  • The NBConvert tool is used to convert notebook files to various formats, such as HTML, through a process involving preprocessing, exporting, and postprocessing.

Jupyter Kernels

A notebook kernel is a computational engine responsible for executing the code within a Notebook file.

Key Concepts

  • Execution: The kernel runs the code cells in the Notebook and returns the results.
  • Language Support: Jupyter supports kernels for multiple languages, commonly used in Data Science.

Working with Kernels

Launching a Kernel

  • Automatic Launch: When a Notebook document is opened, the associated kernel starts automatically.
  • Language Selection: Choose the desired language for your project when launching the notebook.

Kernel Operations

  • Python Kernel:
    • Allows execution of Python code cells.
    • The kernel name (e.g., Python) is displayed in the top right corner of the Notebook interface.

Multi-language Support

  • Pre-installed Kernels in Skills Network Lab:
    • Python
    • Apache
    • Julia
    • R
    • Swift
  • Kernel Selection:
    • Launch Page: Select the desired kernel when starting a notebook.
    • Top Right Icon: Change the kernel from the drop-down menu available in the top right corner of the Notebook.